package com.xxl.util;

import java.sql.*;

public class JDBCUtil {

    private Connection conn;
    public void closeConnection(Connection conn, PreparedStatement ps, ResultSet rs) throws SQLException {
        try {
            if (rs != null) {
                rs.close();
            }
            if (conn != null) {
                conn.close();
            }
            if (ps != null) {
                ps.close();
            }
        } finally {
            System.out.println("JDBCUtil.closeConnection");
        }


    }
    public Connection init() throws ClassNotFoundException, SQLException {
        //注册驱动
        Class.forName("com.mysql.jdbc.Driver");
//        Class.forName("org.sqlite.JDBC");
        //创建连接
        conn = DriverManager.getConnection("jdbc:mysql://47.119.135.214:3306/webhomework?useUnicode=true&characterEncoding=utf8","root","MySQL5.7");
//        conn = DriverManager.getConnection("jdbc:sqlite:/webhomework");
        return conn;
    }
}